<!DOCTYPE html>
<html>
	<!--
		作者：offline
		时间：2018-06-27
		描述：员工岗位调动
	-->

	<head>
		<!-- 引入框架文件 -->
		<link rel="stylesheet" href="../../model/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
		<script type="text/javascript" src="../../model/jquery-2.1.0.js"></script>
		<script type="text/javascript" src="../../model/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
		<link rel="stylesheet" href="../../static/css/ehr.css" />
		<link rel="stylesheet" href="../../static/css/employee.css" />
		<script type="text/javascript" src="../../model/models.js"></script>
		<script type="text/javascript" src="../../model/dispose.js"></script>
		<meta charset="UTF-8">
		<style type="text/css">
			.content input {
				width: 200px;
			}
			
			.content span {
				margin-top: 7px;
			}
		</style>
		<title></title>
	</head>

	<body>

		<div include="../../static/header.htm"></div>
		<div style="height: 100%;float: left;" include="../../static/aside.htm"></div>

		<div class="aside2">
			<div include="../../static/empManage.htm"></div>
		</div>

		<div class="section">
			<div style="color: white;font-size: 36px;text-align: center; width: 100%; height: 70px;" class="head"><b>岗位调换</b></div>
			<div class="content">
				<!-- 查询框 -->
				<div style="margin-bottom: 5px;">
					<form id="findEmp">
						<!-- 搜索输入框 -->
						<input id="cont" placeholder="员工编号/姓名" type="text" style="width: 200px; float: left;" class="form-control" />
						<input style="margin: 2px 5px; width: 100px;" type="submit" value="查询" class="btn btn-danger" />

						<!--<span>员工编号：</span>
						<select class="select" style="width:80px; height:30px; color:#03F">
							<option value="saab">007</option>
						</select>-->
					</form>
				</div>
				<!-- 员工基本信息显示 -->
				<form id="addPostTurn">
					<table class="table table-bordered">
						<tr>
							<td>
								<div class="left">
									<span>员工姓名：</span>
									<input id="empName" type="text" class="form-control" readonly/>
								</div>
							</td>
							<td>
								<div class="right">
									<span>员工编号：</span>
									<input id="id" name="postEmp.id" type="text" class="form-control" readonly/>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">
									<span>部门名称：</span>
									<input id="postName" type="text" class="form-control" readonly/>
								</div>
							</td>
							<td>
								<div class="right">
									<span>部门编号：</span>
									<input id="empDivName" type="text" class="form-control" readonly/>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">
									<span>调动日期：</span>
									<input name="turnDate" type="date" class="form-control" />
								</div>
							</td>
							<td>
								<div class="right">
									<span>调转类型：</span>
									<select name="turnType" style="width: 200px;" class="form-control">
										<option value="升职">升职</option>
										<option value="降职">降职</option>
										<option value="数据录入错误">数据录入错误</option>
									</select>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="left">

									<span>岗　　位：</span>
									<input id="empPostName" type="text" class="form-control" />
									<input type="hidden" id="empPostId" name="frontPost.id" />
								</div>
							</td>
							<td>
								<div class="right">
									<span>调动后岗位：</span>
									<select id="post" name="turnPost.id" style="width: 200px;" class="form-control">
										<option value="2">Java高级工程师</option>
									</select>
								</div>
							</td>
						</tr>

						<tr style="border: none;">
							<td style="border: none;">
								<div>
									<span style="float: left;">调转原因：</span>
									<textarea name="turnCause" class="form-control" style="height: 70px;"></textarea>
								</div>
							</td>
							<td style="border: none;">
								<div>
									<span style="float: left;">备　　注：</span>
									<textarea name="note" class="form-control" style="height: 70px;"></textarea>
								</div>
							</td>
						</tr>
					</table>

					<!-- 提交按钮 -->
					<div style="margin: 0 auto; width: 200px; height: 70px; margin-top: 40px;">
						<input class="btn btn-danger" style="width: 200px;" type="submit" value="提交" />
					</div>
				</form>
			</div>
		</div>

	</body>

	<script type="text/javascript">
		// 查询所有的部门信息并进行下拉框更新 传入select的id名
		findPostAll("post");

		function getUrlParam(param) {
			var reg = new RegExp("(^|&)" + param + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
			var r = window.location.search.substr(1).match(reg); //匹配目标参数
			if(r != null) return decodeURI(r[2]);
			return null; //返回参数值
		}

		var id = getUrlParam("id");

		if(null != id) {
			$.ajax({
				type: "post",
				url: "http://localhost:9090/findEmpById?id=" + id,
				"success": function(obj) {
					if(obj.data != null) {
						var emp = obj.data;

						for(var index in emp) {
							if("empPost" == index) {
								$("#" + index + "Name").val(emp[index].postName);
								$("#" + index + "Id").val(emp[index].id);
							} else
								$("#" + index).val(emp[index]);
						}

						$("#empDivId").val(emp.empDiv.id);
						$("#empDivName").val(emp.empDiv.depaName);

					} else
						window.wxc.xcConfirm("无此用户！", window.wxc.xcConfirm.typeEnum.error);
				},
				"dataType": "json",
				async: true
			});
		}

		$("#findEmp").submit(function(e) {
			e.preventDefault();
			var cont = $("#cont").val();
			//jq的回调函数中的this,一般表示该事件源,即触发事件的元素
			var $self = $(this);

			//$self.serialize(); 将表单中的数据进行序列化
			//async:true 采用异步操作
			$.ajax({
				type: "post",
				url: "http://localhost:9090/findEmpById?id=" + cont,
				"data": $self.serialize(),
				"success": function(obj) {
					if(obj.data != null) {
						var emp = obj.data;

						for(var index in emp) {
							if("empPost" == index) {
								$("#" + index + "Name").val(emp[index].postName);
								$("#" + index + "Id").val(emp[index].id);
							} else
								$("#" + index).val(emp[index]);
						}

						$("#empDivId").val(emp.empDiv.id);
						$("#empDivName").val(emp.empDiv.depaName);

					} else
						window.wxc.xcConfirm("无此用户！", window.wxc.xcConfirm.typeEnum.error);
				},
				"dataType": "json",
				async: true
			});
		});

		$("#addPostTurn").submit(function(e) {
			e.preventDefault();
			//jq的回调函数中的this,一般表示该事件源,即触发事件的元素
			var $self = $(this);

			//$self.serialize(); 将表单中的数据进行序列化
			//async:true 采用异步操作
			$.ajax({
				type: "post",
				url: "http://localhost:9090/addPostTurn",
				"data": $self.serialize(),
				"success": function(obj) {
					if(obj.data) {

						window.wxc.xcConfirm("岗位调动成功！", "success")

					} else
						window.wxc.xcConfirm("无此用户！", window.wxc.xcConfirm.typeEnum.error);
				},
				"dataType": "json",
				async: true
			});
		});
	</script>

</html>